const {
    editBasics,
    hqzl
} = require('../service/basics.service')
const { error, getError } = require("../constant/err.type");
const { success, text } = require("../constant");
class BasicsController {
    async compile (ctx, next) {
        try {
            const res = await editBasics ({...ctx.request.body, userId: ctx.state.user.id})
            ctx.body = {
                code: success,
                message: text.success,
                result: {
                    id: res.id,
                    userName: res.userName
                }
            }
        } catch (err) {
            ctx.app.emit('error', error, ctx)
        }
    }
    async getInfo (ctx) {
        try {
           const res = await hqzl(ctx.state.user.id)
            ctx.body = {
                code: success,
                message: text.success,
                result: res
            }
        } catch (err) {
            ctx.app.emit('error', getError, ctx)
        }
    }
}
module.exports = new BasicsController()
